perf(util-endpoints): reduce temporary object allocations#1957
perf(util-endpoints): reduce temporary object allocations#1957
Conversation
…ent in evaluateEndpointRule
b96ce29 to
6a00f07
Compare
| ...options.referenceRecord, | ||
| ...conditionsReferenceRecord, | ||
| }, | ||
| }); |
There was a problem hiding this comment.
how can we confirm no edge case relied on this? the diff seems to result in a potentially different set of objects
if it can be proven this is all part of the same evaluation's lifecycle, maybe even the initial copy isn't necessary.
There was a problem hiding this comment.
one thing we could do is run the full AWS endpoint test suite
There was a problem hiding this comment.
We're not changing the behavior. The conditionOptions object was additive even before. We're just not creating new object for every call.
The test needs to check the first call received an empty referenceRecord at call time, but the spy only holds a reference that's since been mutated. That's why tests had to be updated.
ccc8015 to
78eb850
Compare
| const conditionOptions: EvaluateOptions = { | ||
| ...options, | ||
| referenceRecord: { ...options.referenceRecord }, | ||
| }; |
There was a problem hiding this comment.
is it safe to use options all the way through with no copying?
Why I think it might be safe: options object lifecycle is one endpoint resolution, and this is all synchronous code...
Issue
Internal JS-6645
Description
Remove rest spread destructuring that created a new object on every call, and replace conditional spread in the return with an early return branch to avoid temporary object allocation.
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.